package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LogoutServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //退出登陆，清空session域
        request.getSession().removeAttribute("member"); //清除当前用户个人中心
        request.getSession().removeAttribute("result"); //清除当前用户购物车中的总金额
        request.getSession().removeAttribute("shopCar"); //清除当前用户的 购物车
        request.getSession().removeAttribute("username");
        request.getSession().removeAttribute("order");
        request.getSession().removeAttribute("ordered");
        request.getSession().removeAttribute("orderCar");
        request.getSession().removeAttribute("orderCared");
        response.sendRedirect("index.jsp");
    }
}
